home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-06-21 | 1.9 KB | 90 lines | [TEXT/CWIE] |
-
- #include <A4Stuff.h>
- #include <SetUpA4.h>
- #include <Traps.h>
- #include <Windows.h>
- #include <Resources.h>
- #include <Sound.h>
-
-
- typedef pascal OSErr (*PostEventType)(short eventNum,long eventMsg);
- PostEventType oldPostEvent;
-
- typedef pascal void (*ProcessMgrDispatchType)(short selector);
- ProcessMgrDispatchType oldProcessMgrDispatch;
-
- static pascal OSErr myPostEvent2(short eventNum,long eventMsg)
- {
- short resultCode = noErr;
- Boolean doIt = true;
-
- EnterCallback();
- if ( eventNum == mouseDown )
- {
- WindowPeek frontWindow = (WindowPeek)FrontWindow();
- if ( frontWindow && !PtInRgn( LMGetRawMouseLocation(), frontWindow->strucRgn ) )
- {
- RgnHandle rgn = NewRgn();
- CopyRgn( frontWindow->strucRgn, rgn );
- InsetRgn( rgn, -10, 0 );
- if ( PtInRgn( LMGetRawMouseLocation(), frontWindow->strucRgn ) )
- {
- SysBeep(5);
- doIt = false;
- }
- DisposeRgn( rgn );
- }
- }
-
- if (doIt)
- resultCode = (oldPostEvent)(eventNum, eventMsg);
- ExitCallback();
- return resultCode;
- }
-
- asm static pascal OSErr myPostEvent(short eventNum,long eventMsg)
- {
- link a6,#0
- move.l a0,-(a7)
- move.l d0,-(a7)
- jsr myPostEvent2
- move.l (a7)+,d0
- unlk a6
- rts
- }
-
-
- static pascal void myWatchForProcessMgr(short selector)
- {
- ProcessMgrDispatchType localTrapAddress;
-
- EnterCodeResource();
-
- if (selector == 1)
- {
- // install findwindow patch here
- oldPostEvent = (PostEventType)GetOSTrapAddress( _PostEvent );
- SetOSTrapAddress( (UniversalProcPtr)myPostEvent, _PostEvent );
- }
-
- localTrapAddress = oldProcessMgrDispatch;
- ExitCodeResource();
-
- (*oldProcessMgrDispatch)(selector);
- }
-
- void main( void )
- {
- EnterCodeResource();
- PrepareCallback();
-
- Handle myHandle = Get1Resource( 'INIT', 300 );
- DetachResource( myHandle );
- HLock( myHandle );
-
- oldProcessMgrDispatch = (ProcessMgrDispatchType)GetToolTrapAddress( 0xABCF );
- SetToolTrapAddress( (UniversalProcPtr)myWatchForProcessMgr, 0xABCF );
-
- ExitCodeResource();
- }
-